1 /**************************************************************************\ 2 * 3 * Copyright (c) 1998-2000, Microsoft Corp. All Rights Reserved. 4 * 5 * Module Name: 6 * 7 * Gdiplus pixel formats 8 * 9 * Abstract: 10 * 11 * Definitions for color types, palettes, pixel format IDs. 12 * 13 \**************************************************************************/ 14 15 #ifndef _GDIPLUSPIXELFORMATS_H 16 #define _GDIPLUSPIXELFORMATS_H 17 18 /* 19 * 32-bit and 64-bit ARGB pixel value 20 */ 21 22 typedef DWORD ARGB; 23 typedef DWORDLONG ARGB64; 24 25 #define ALPHA_SHIFT 24 26 #define RED_SHIFT 16 27 #define GREEN_SHIFT 8 28 #define BLUE_SHIFT 0 29 #define ALPHA_MASK ((ARGB) 0xff << ALPHA_SHIFT) 30 31 /* 32 * In-memory pixel data formats: 33 * bits 0-7 = format index 34 * bits 8-15 = pixel size (in bits) 35 * bits 16-23 = flags 36 * bits 24-31 = reserved 37 */ 38 39 #ifndef DCR_USE_NEW_105760 40 41 enum PixelFormat 42 { 43 PixelFormatIndexed = 0x00010000, // Indexes into a palette 44 PixelFormatGDI = 0x00020000, // Is a GDI-supported format 45 PixelFormatAlpha = 0x00040000, // Has an alpha component 46 PixelFormatPAlpha = 0x00080000, // Uses pre-multiplied alpha 47 PixelFormatExtended = 0x00100000, // Uses extended color (16 bits per channel) 48 PixelFormatCanonical = 0x00200000, // ? 49 50 PixelFormatUndefined = 0, 51 PixelFormatDontCare = 0, 52 53 PixelFormat1bppIndexed = 1 | ( 1 << 8) | PixelFormatIndexed 54 | PixelFormatGDI, 55 PixelFormat4bppIndexed = 2 | ( 4 << 8) | PixelFormatIndexed 56 | PixelFormatGDI, 57 PixelFormat8bppIndexed = 3 | ( 8 << 8) | PixelFormatIndexed 58 | PixelFormatGDI, 59 PixelFormat16bppGrayScale = 4 | (16 << 8) | PixelFormatExtended, 60 PixelFormat16bppRGB555 = 5 | (16 << 8) | PixelFormatGDI, 61 PixelFormat16bppRGB565 = 6 | (16 << 8) | PixelFormatGDI, 62 PixelFormat16bppARGB1555 = 7 | (16 << 8) | PixelFormatAlpha 63 | PixelFormatGDI, 64 PixelFormat24bppRGB = 8 | (24 << 8) | PixelFormatGDI, 65 PixelFormat32bppRGB = 9 | (32 << 8) | PixelFormatGDI, 66 PixelFormat32bppARGB = 10 | (32 << 8) | PixelFormatAlpha 67 | PixelFormatGDI 68 | PixelFormatCanonical, 69 PixelFormat32bppPARGB = 11 | (32 << 8) | PixelFormatAlpha 70 | PixelFormatPAlpha 71 | PixelFormatGDI, 72 PixelFormat48bppRGB = 12 | (48 << 8) | PixelFormatExtended, 73 PixelFormat64bppARGB = 13 | (64 << 8) | PixelFormatAlpha 74 | PixelFormatCanonical 75 | PixelFormatExtended, 76 PixelFormat64bppPARGB = 14 | (64 << 8) | PixelFormatAlpha 77 | PixelFormatPAlpha 78 | PixelFormatExtended, 79 PixelFormat24bppBGR = 15 | (24 << 8) | PixelFormatGDI, 80 PixelFormatMax = 16 81 }; 82 83 #else 84 85 typedef INT PixelFormat; 86 87 #define PixelFormatIndexed 0x00010000 // Indexes into a palette 88 #define PixelFormatGDI 0x00020000 // Is a GDI-supported format 89 #define PixelFormatAlpha 0x00040000 // Has an alpha component 90 #define PixelFormatPAlpha 0x00080000 // Uses pre-multiplied alpha 91 #define PixelFormatExtended 0x00100000 // Uses extended color (16 bits per channel) 92 #define PixelFormatCanonical 0x00200000 // ? 93 94 #define PixelFormatUndefined 0 95 #define PixelFormatDontCare 0 96 97 #define PixelFormat1bppIndexed (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI) 98 #define PixelFormat4bppIndexed (2 | ( 4 << 8) | PixelFormatIndexed | PixelFormatGDI) 99 #define PixelFormat8bppIndexed (3 | ( 8 << 8) | PixelFormatIndexed | PixelFormatGDI) 100 #define PixelFormat16bppGrayScale (4 | (16 << 8) | PixelFormatExtended) 101 #define PixelFormat16bppRGB555 (5 | (16 << 8) | PixelFormatGDI) 102 #define PixelFormat16bppRGB565 (6 | (16 << 8) | PixelFormatGDI) 103 #define PixelFormat16bppARGB1555 (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI) 104 #define PixelFormat24bppRGB (8 | (24 << 8) | PixelFormatGDI) 105 #define PixelFormat32bppRGB (9 | (32 << 8) | PixelFormatGDI) 106 #define PixelFormat32bppARGB (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical) 107 #define PixelFormat32bppPARGB (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI) 108 #define PixelFormat48bppRGB (12 | (48 << 8) | PixelFormatExtended) 109 #define PixelFormat64bppARGB (13 | (64 << 8) | PixelFormatAlpha | PixelFormatCanonical | PixelFormatExtended) 110 #define PixelFormat64bppPARGB (14 | (64 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatExtended) 111 #define PixelFormatMax 15 112 113 #endif 114 115 116 /* 117 * Return the pixel size for the specified format (in bits) 118 */ 119 120 inline UINT 121 GetPixelFormatSize( 122 PixelFormat pixfmt 123 ) 124 { 125 return (pixfmt >> 8) & 0xff; 126 } 127 128 /* 129 * Determine if the specified pixel format is an indexed color format 130 */ 131 132 inline BOOL 133 IsIndexedPixelFormat( 134 PixelFormat pixfmt 135 ) 136 { 137 return (pixfmt & PixelFormatIndexed) != 0; 138 } 139 140 /* 141 * Determine if the pixel format can have alpha channel 142 */ 143 144 inline BOOL 145 IsAlphaPixelFormat( 146 PixelFormat pixfmt 147 ) 148 { 149 return (pixfmt & PixelFormatAlpha) != 0; 150 } 151 152 /* 153 * Determine if the pixel format is an extended format, 154 * i.e. supports 16-bit per channel 155 */ 156 157 inline BOOL 158 IsExtendedPixelFormat( 159 PixelFormat pixfmt 160 ) 161 { 162 return (pixfmt & PixelFormatExtended) != 0; 163 } 164 165 /* 166 * Determine if the pixel format is canonical format: 167 * PixelFormat32bppARGB 168 * PixelFormat32bppPARGB 169 * PixelFormat64bppARGB 170 * PixelFormat64bppPARGB 171 */ 172 173 inline BOOL 174 IsCanonicalPixelFormat( 175 PixelFormat pixfmt 176 ) 177 { 178 return (pixfmt & PixelFormatCanonical) != 0; 179 } 180 181 /* 182 * Color palette 183 * palette entries are limited to 32bpp ARGB pixel format 184 */ 185 186 enum PaletteFlags 187 { 188 PaletteFlagsHasAlpha = 0x0001, 189 PaletteFlagsGrayScale = 0x0002, 190 PaletteFlagsHalftone = 0x0004 191 }; 192 193 struct ColorPalette 194 { 195 public: 196 UINT Flags; // palette flags 197 UINT Count; // number of color entries 198 ARGB Entries[1]; // palette color entries 199 }; 200 201 #endif 202